package com.cin.cma.server.pos.controller;


import com.cin.cma.common.model.ApiResponse;
import com.cin.cma.server.pos.config.SocketIOService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date：2024-07-16 14:45
 */
@Slf4j
@RestController
public class MainController {

    @GetMapping("/")
    public String index() {
        log.info("success");
        return "success";
    }

    @ResponseBody
    @GetMapping("getOnlineClients")
    public ApiResponse<List<String>> getOnlineClients() {
        List<String> onlineClients = new ArrayList<>();
        SocketIOService.clientMap.forEach((key, s) -> onlineClients.add(key));
        return ApiResponse.success(onlineClients);
    }
}
